package cn.akwangl.concurrency.web.config;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * ZK 配置类.
 *
 * @author 阿坤同学
 * @date 2022-11-25 11:23
 */
@Configuration
public class ZkConfig {

    /**
     * ZK 客户端.
     *
     * @author 阿坤同学
     * @date 2022-11-25 11:24
     */
    @Bean(initMethod = "start", destroyMethod = "close")
    public CuratorFramework zkClient() {
        RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
        CuratorFramework client = CuratorFrameworkFactory.newClient("123.249.18.14:2181", retryPolicy);
        return client;
    }
}
